package com.qidianit.mes.pro.controller;

import com.github.pagehelper.PageInfo;
import com.qidianit.mes.pojo.ProductionOrder;
import com.qidianit.mes.pojo.Result;
import com.qidianit.mes.pro.service.ProductionOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ Description:
 * @ Author:WuJingLei
 * @ Date: 2025/9/20 -15:51
 */
@RestController
@RequestMapping("/productionOrder")
public class ProductionOrderController {
    @Autowired
    private ProductionOrderService productionOrderService;

    @GetMapping("/page")
    public Result<PageInfo<ProductionOrder>> page(ProductionOrder productionOrder,
                                                  @RequestParam(defaultValue = "1") int pageNum,
                                                  @RequestParam(defaultValue = "10") int pageSize){
        return productionOrderService.queryList(productionOrder,pageNum,pageSize);
    }

    @GetMapping("/{id}")
    public Result<ProductionOrder> queryById(@PathVariable Long id){
        return productionOrderService.queryById(id);
    }

    @PutMapping("/update")
    public Result update(@RequestBody ProductionOrder productionOrder){
        return productionOrderService.updateById(productionOrder);
    }

    @PostMapping("/add")
    public Result<ProductionOrder> add(@RequestBody ProductionOrder productionOrder){
        return productionOrderService.addProductionOrder(productionOrder);
    }

    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable Long id){
        return productionOrderService.delete(id);
    }


}
